package com.baomidou.blog.controller;

import com.baomidou.blog.entity.Article;
import com.baomidou.blog.service.IArticleService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ArticleController {


    @Autowired
    private IArticleService articleService;

    @RequestMapping("/list/{id:\\d+}")
    public Page articlelist(@PathVariable("id") int id){

        EntityWrapper<Article> entityWrapper  = new EntityWrapper();
        return articleService.selectPage(new Page<Article>(id, 12), entityWrapper);
    }

    @RequestMapping("/list")
    public Page articlelist(){

        EntityWrapper<Article> entityWrapper  = new EntityWrapper();
        return articleService.selectPage(new Page<Article>(0, 12), entityWrapper);
    }



}
